<template>
    <div>
        <h1>查看{{ clazzName }}班课程安排</h1>
        <el-table :data="courseSchedules" style="width: 100%">
            <el-table-column prop="courseName" label="课程名称" />
            <el-table-column prop="week" label="周数" />
            <el-table-column prop="day" label="星期几" />
            <el-table-column prop="startPeriod" label="开始节次" />
            <el-table-column prop="endPeriod" label="结束节次" />
        </el-table>
    </div>
</template>

<script>
import service from '@/api';
export default {
    data() {
        return {
            clazzId: null,
            clazzName: '',
            courseSchedules: []
        }
    },
    created() {
        this.clazzId = this.$route.params.clazzId;
        this.fetchData();
    },
    methods: {
        async fetchData() {
            const clazz = await service.get(`/api/clazz/${this.clazzId}`, null, "获取班级信息");
            this.clazzName = clazz.name;
            this.courseSchedules = await service.get(`/api/courses_schedule/clazz/${this.clazzId}`, "获取课程安排");
        }
    }
}
</script>

<style scoped></style>